package com.sikaryofficial.backend.constant;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;
import java.util.Objects;

/**
 * @author : qinjinyuan
 * @desc : 协议类型枚举
 * @date : 2023/11/04 10:08
 */
@Getter
@AllArgsConstructor
public enum ProtocolTypeEnum {

    /**
     * 协议类型：1-用户协议,2-隐私协议
     */
    USER(1, "用户协议"),
    /**
     * 协议类型：1-用户协议,2-隐私协议
     */
    PRIVACY(2, "隐私协议");
    private final Integer protocolType;
    private final String description;

    public static ProtocolTypeEnum getEnum(Integer code) {
        return Arrays.stream(ProtocolTypeEnum.values())
                .filter(pointRuleEnum -> Objects.nonNull(code) &&  pointRuleEnum.getProtocolType().equals(code))
                .findFirst().orElse(null);
    }
}
